package com.wash.shoes.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.wash.shoes.domain.dto.RegionDistributorDto;
import com.wash.shoes.domain.vo.RegionDistributorVo;
import com.wash.shoes.entity.OrderTransportPo;
import com.wash.shoes.entity.RegionDistributorPo;
import com.wash.shoes.page.PageFactory;
import com.wash.shoes.service.RegionDistributorService;
import com.wash.shoes.mapper.RegionDistributorMapper;
import com.wash.shoes.util.CurrenciesUtil;
import com.wash.shoes.util.HeaderUtil;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
* @author jianguoli
* @description 针对表【os_region_distributor(分销商,按照区域分销)】的数据库操作Service实现
* @createDate 2025-03-10 14:47:55
*/
@Service
public class RegionDistributorServiceImpl extends ServiceImpl<RegionDistributorMapper, RegionDistributorPo>
    implements RegionDistributorService{


    @Override
    public Page<RegionDistributorVo> pageList(RegionDistributorDto regionDistributorDto) {
        Page<RegionDistributorVo> page = PageFactory.defaultPage();
        List<RegionDistributorVo> dataList = baseMapper.pageList(page, regionDistributorDto);
        Optional.ofNullable(dataList)
                .orElse(Lists.newArrayList())
                .forEach(vo -> vo.setPromotionProfit(CurrenciesUtil.keepDecimals(vo.getPromotionSum())));
        page.setRecords(dataList);
        return page;
    }

    @Override
    public RegionDistributorPo getByUserId(String userId) {
        return this.baseMapper.getByUserId(userId);
    }

    public RegionDistributorVo cober(RegionDistributorVo vo) {
        return new RegionDistributorVo();

    }
}




